import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { TRandRewardConfig } from "../../../Message/Db/Tables/TRandRewardConfig";
type int = number;
//class RandRewardConfig
    
    export  class RandRewardConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            if (RandRewardConfig._instance != null) 
            {
                throw new Error(" RandRewardConfig 单例 ");
            }
            this.init();
            return;
        }

        protected init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_rand_reward_config.json");
            this.write(loc1);
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TRandRewardConfig();
                loc1.id = loc2.id;
                loc1.code = loc2.code;
                loc1.type = loc2.type;
                loc1.intExtend = loc2.intExtend;
                loc1.rate = loc2.rate;
                loc1.num = loc2.num;
                loc1.needBroadcast = loc2.needBroadcast;
                if (!this._map[loc1.type]) 
                {
                    this._map[loc1.type] = new Array<any>();
                }
                (this._map[loc1.type] as Array<any>).push(loc1);
            }
            return;
        }

        public getRewardsByType(arg1: int): Array<any>
        {
            return this._map[arg1];
        }

        public static get instance(): RandRewardConfig
        {
            if (RandRewardConfig._instance == null) 
            {
                RandRewardConfig._instance = new RandRewardConfig();
            }
            return RandRewardConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: RandRewardConfig;
    }
